/*
 * @Author: DT1604\ZPL zhoupeili@dpc.com.cn
 * @Date: 2022-09-20 11:32:08
 * @LastEditors: DT1604\ZPL zhoupeili@dpc.com.cn
 * @LastEditTime: 2022-09-20 11:32:27
 * @FilePath: \eoms-ui\src\utils\messageBox.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/**
 * elementUI messageBox 方法封装
 */

import {
  MessageBox
} from "element-ui";

//确认弹窗
/*
使用：
handleConfirm('确定执行此操作吗？', 'warning' , '标题').then(res => {
                // do something
     }).catch(err => {
                // do something cancel
     });
*/

let handleConfirm = (text = '确定执行此操作吗？', type = 'warning', title = '提示') => {
  return MessageBox.confirm(text, title, {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: type,
  })
};

//alert弹窗
/*
使用：
handleAlert('提交数据成功！', 'success')
.then(res => {
      // then() 可省略
     })
*/

let handleAlert = (text = '操作成功。', type = 'success') => {
  return MessageBox.confirm(`<span style="font-size: 1.2rem;margin-top: -1rem;margin-bottom: 0.4rem;display: block;">${text}</span>`, {
    confirmButtonText: '关闭',
    cancelButtonText: '',
    showCancelButton: false,
    dangerouslyUseHTMLString: true,
    type: type,
    center: true
  })
};


export {
  handleConfirm,
  handleAlert
}
